package com.enjoyor.soa.traffic.server.efoms.dubbo.manage;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.enjoyor.soa.traffic.api.dto.efoms.VideoRelationInfoDto;
import com.enjoyor.soa.traffic.core.efoms.domain.VideoRelationInfo;
import com.enjoyor.soa.traffic.core.efoms.service.IVideoRelationInfoService;
import com.enjoyor.soa.traffic.util.helper.ReflectHelper;
import com.enjoyor.soa.traffic.util.helper.ResultHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

@Service(timeout = 6000)
public class ManageVideoRelationInfoService {

	@Autowired
	private IVideoRelationInfoService videoRelationInfoService;

	public ResultPojo getVideoRelationInfo(String videoRelationId) {
		VideoRelationInfo videoRelationInfo = videoRelationInfoService.getVideoRelationInfo(videoRelationId);
		return ResultHelper.getResult(ReflectHelper.beanToBean(videoRelationInfo, VideoRelationInfoDto.class));
	}

	public ResultPojo getVideoRelationPage(String videoRelationId, String videoGroupId,String key,Page page) {
		return ResultHelper.getResult(videoRelationInfoService.getVideoRelationInfoPage(videoRelationId, videoGroupId,key,page));
	}

	public ResultPojo getVideoRelationList(String videoRelationId, String videoGroupId,String key) {
		List<VideoRelationInfo> list = videoRelationInfoService.getVideoRelationInfoList(videoRelationId, videoGroupId,key);
		return ResultHelper.getResult(ReflectHelper.listToList(list, VideoRelationInfoDto.class));
	}

	public ResultPojo insertVideoRelationInfo(List<VideoRelationInfoDto> rltList,String videoGroupId,String userName) {
		List<VideoRelationInfo> videoRelationList = ReflectHelper.listToList(rltList, VideoRelationInfo.class);
		return videoRelationInfoService.insertVideoRelationInfo(videoRelationList,videoGroupId,userName);
	}

	public ResultPojo updateVideoRelationInfo(VideoRelationInfoDto videoRelationInfoDto, String userName) {
		VideoRelationInfo videoRelationInfo = ReflectHelper.beanToBean(videoRelationInfoDto, VideoRelationInfo.class);
		return videoRelationInfoService.updateVideoRelationInfo(videoRelationInfo, userName);
	}

	public ResultPojo deleteVideoRelationInfo(String videoGroupId,String userName) {
		return videoRelationInfoService.deleteVideoRelationInfo(videoGroupId, userName);
	}
	
	public ResultPojo deleteVideoReletionByGroupIdAndVideoId(List<VideoRelationInfoDto> listVideoRelationInfoDto,String userName){
		List<VideoRelationInfo> listVideoRelationInfo = ReflectHelper.listToList(listVideoRelationInfoDto, VideoRelationInfo.class);
		return videoRelationInfoService.deleteVideoReletionByGroupIdAndVideoId(listVideoRelationInfo, userName);
	}

}
